Skip to content

feat(inst/langchain4j): add LangChain4j 1.0 phase attribution instrumentation#11530

Closed
jbachorik wants to merge 1 commit into
jb/llm-ddt-2-profilerfrom
jb/llm-ddt-3-lc4j
Closed

feat(inst/langchain4j): add LangChain4j 1.0 phase attribution instrumentation#11530
jbachorik wants to merge 1 commit into
jb/llm-ddt-2-profilerfrom
jb/llm-ddt-3-lc4j

Conversation

@jbachorik

@jbachorik jbachorik commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

What Does This Do

New instrumentation module dd-java-agent/instrumentation/langchain4j/langchain4j-1.0 with three InstrumenterModule.Profiling hooks tagging LangChain4j 1.0 pipeline boundaries:

Class Hook point Phase set
ChatModelInstrumentation ChatModel#chat(ChatRequest) — all implementations awaiting_inference
ToolExecutorInstrumentation ToolExecutor#execute(ToolExecutionRequest, Object) tool_execution
AiServicesInstrumentation DefaultAiServices$1#invoke(...) (anonymous InvocationHandler) context_build

Each advice sets llm.agent.phase on enter via Profiling.get().newScope().setContextValue(...) and clears on exit. Muzzle passes LC4j versions 1.0.0–1.15.1.

Motivation

LangChain4j uses its own HTTP client — the existing OpenAI Java SDK instrumentation does not fire on LC4j calls. Without this module, CPU flamegraphs from LC4j services show undifferentiated work.

Part of PROF-14858. Stacked on #11529 (DatadogProfiler slot). Next: [ddt-4-demo] (demo app).

Additional Notes

  • Activated only when TargetSystem.PROFILING is enabled (InstrumenterModule.Profiling).
  • ToolExecutor is at dev.langchain4j.service.tool (not agent.tool as the spec guessed).
  • AiServices handler is the anonymous class DefaultAiServices$1.
  • langchain4j-ollama 1.0.0 does not exist in Maven Central; earliest 1.x is 1.2.0.

Contributor Checklist

  • Format the title according to the contribution guidelines
  • Assign the type: and (comp: or inst:) labels in addition to any other useful labels
  • Avoid using close, fix, or any linking keywords when referencing an issue
    Use solves instead, and assign the PR milestone to the issue
  • Update the CODEOWNERS file on source file addition, migration, or deletion
  • Update public documentation with any new configuration flags or behaviors
  • Add your completed PR to the merge queue by commenting /merge. You can also:
    • Customize the commit message associated with the merge with /merge --commit-message "..."
    • Remove your PR from the merge queue with /merge -c
    • Skip all merge queue checks with /merge -f --reason "reason"; please use this judiciously, as some checks do not run at the PR-level
    • Get more information in this doc

Jira ticket: PROF-14863

@datadog-datadog-prod-us1-2

datadog-datadog-prod-us1-2 Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Pipelines

Fix all issues with BitsAI

⚠️ Warnings

🚦 15 Pipeline jobs failed

DataDog/apm-reliability/dd-trace-java | spotless   View in Datadog   GitLab

🔧 Fix in code (Fix with Cursor). Format violations in src/main/java/com/datadog/profiling/ddprof/DatadogProfiler.java. Run './gradlew spotlessApply' to fix.

Run system tests | main / End-to-end #4 / spring-boot-openliberty 4   View in Datadog   GitHub Actions

🔧 Fix in code (Fix with Cursor). 1 failed test. AssertionError: assert not ['[dd.trace 2026-06-02 13:33:56:311 +0000] [dd-jmx-collector] WARN org.datadog.jmxfetch.tasks.TaskProcessor - JMXFetch... com.ibm.ws.webcontainer.webapp.WebAppErrorReport: SRVE0295E: Error reported: 500\n']

Run system tests | main / End-to-end #5 / spring-boot 5   View in Datadog   GitHub Actions

🔧 Fix in code (Fix with Cursor). 1 failed test due to assertion error. AssertionError: Request failed: None at tests/ffe/test_dynamic_evaluation.py:237.

View all 15 failed jobs.

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: c8dab32 | Docs | Datadog PR Page | Give us feedback!

@PerfectSlayer PerfectSlayer added tag: ai generated Largely based on code generated by an AI or LLM and removed AI labels Jun 3, 2026
@jbachorik jbachorik closed this Jun 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tag: ai generated Largely based on code generated by an AI or LLM

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants